package cn.xfdzx.android.apps.shop.activity.ruzhu;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.OnClick;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.apps.Constants;
import cn.xfdzx.android.apps.shop.base.BaseMvpActivity;
import cn.xfdzx.android.apps.shop.bean.ConmitData_Bean;
import cn.xfdzx.android.apps.shop.bean.GetJieguoBeen;
import cn.xfdzx.android.apps.shop.bean.Store_informationBean;
import cn.xfdzx.android.apps.shop.contract.InformationContract;
import cn.xfdzx.android.apps.shop.presenter.InformationPresenter;

public class InformationActivity<instance> extends BaseMvpActivity<InformationPresenter> implements InformationContract.View {


    @BindView(R.id.ll_state)
    LinearLayout llState;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.rl_title)
    RelativeLayout rlTitle;
    @BindView(R.id.tv_title_name)
    TextView tvTitleName;
    @BindView(R.id.ett_retail_information_name)
    TextView ettRetailInformationName;
    @BindView(R.id.ll_retail_shop_information)
    RelativeLayout llRetailShopInformation;
    @BindView(R.id.tv_retail_qualifications_name)
    TextView tvRetailQualificationsName;
    @BindView(R.id.ett_retail_qualifications_name)
    TextView ettRetailQualificationsName;
    @BindView(R.id.ll_retail_qualifications_name)
    RelativeLayout llRetailQualificationsName;
    @BindView(R.id.tv_retail_shopowner_name)
    TextView tvRetailShopownerName;
    @BindView(R.id.ett_retail_shopowner_name)
    TextView ettRetailShopownerName;
    @BindView(R.id.ll_retail_shopowner_name)
    RelativeLayout llRetailShopownerName;
    @BindView(R.id.tv_retail_contract_name)
    TextView tvRetailContractName;
    @BindView(R.id.ett_retail_contract_name)
    TextView ettRetailContractName;
    @BindView(R.id.ll_retail_shop_name)
    RelativeLayout llRetailShopName;
    @BindView(R.id.tv_yi_du)
    TextView tvYiDu;
    private String step;
    private String storid;
    private Store_informationBean store_informationBean;
    public static InformationActivity instance;
    public Context mContext;

    @Override
    public int getLayoutId() {
        return R.layout.activity_information;
    }

    @Override
    public void initView() {
        instance=this;
        mPresenter = new InformationPresenter();
        mPresenter.attachView(this);
        mPresenter.forstate("");
        mContext = this;

    }



    @SuppressLint("ResourceAsColor")
    @Override
    public void ontStateType(Store_informationBean bean) {
        store_informationBean = new Store_informationBean();
        store_informationBean = bean;
        storid = bean.getData().getStore_id() + "";
        Log.e("zhuangtai", bean.getData().toString() + bean.getStatus() + bean.getMsg() + "");
        if (bean.getStatus() == Constants.SUCCESS_CODE) {
            if (bean.getData().getOne().isIs_perfect() == true) {
                ettRetailInformationName.setText("已完善");
                ettRetailInformationName.setTextColor(getResources().getColor(R.color.colorPrimary));
            } else {

                ettRetailInformationName.setTextColor(getResources().getColor(R.color.color_FA0303));
            }
            if (bean.getData().getTwo().isIs_perfect() == false) {
                ettRetailQualificationsName.setTextColor(getResources().getColor(R.color.color_FA0303));
            } else {
                ettRetailQualificationsName.setText("已完善");
                ettRetailQualificationsName.setTextColor(getResources().getColor(R.color.colorPrimary));
            }
            if (bean.getData().getThree().isIs_perfect() == false) {
                ettRetailShopownerName.setTextColor(getResources().getColor(R.color.color_FA0303));
            } else {
                ettRetailShopownerName.setText("已完善");
                ettRetailShopownerName.setTextColor(getResources().getColor(R.color.colorPrimary));
            }
        }
    }

    @Override
    public void onConmit(ConmitData_Bean bean) {
        Log.e("ceasdasdasdasd",bean.getMsg()+bean.getStatus()+bean.getData().toString());
    }

    @Override
    public void onJieGuo(GetJieguoBeen been) {
    }



    @Override
    protected void onResume() {
        super.onResume();
        initView();
        Log.e("jishishuxin","zou-----------");
    }


    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void onError(Throwable throwable) {

    }


    @OnClick({R.id.ll_retail_shop_information, R.id.tv_yi_du, R.id.ll_retail_qualifications_name, R.id.ll_retail_shopowner_name, R.id.ll_retail_shop_name, R.id.iv_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_retail_shop_information:
                Intent intent = new Intent(this, Store_informationActivity.class);
                intent.putExtra("stoid", storid);

                startActivity(intent);
                break;
            case R.id.ll_retail_qualifications_name:
                Intent intenttwo = new Intent(this, QualificationsActivity.class);
                intenttwo.putExtra("stoid", storid);

                startActivity(intenttwo);
                break;
            case R.id.ll_retail_shopowner_name:
                Intent intentthree = new Intent(this, Shop_OwnerActivity.class);
                intentthree.putExtra("stoid", storid);

                startActivity(intentthree);
                break;
            case R.id.ll_retail_shop_name:
                break;
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_yi_du:
                if (store_informationBean.getData().getOne().isIs_perfect() == true && store_informationBean.getData().getTwo().isIs_perfect() == true
                        && store_informationBean.getData().getThree().isIs_perfect() == true) {
                    Log.e("stoid", storid + "");
                    mPresenter.forConmit(storid + "");
                    Intent intent1 = new Intent(this, ExamineActivity.class);
                    startActivity(intent1);
                } else {
                    Toast.makeText(mContext, "请确认信息填写完整后提交！", Toast.LENGTH_SHORT).show();

                }

                break;
            default:
                break;
        }
    }


    @OnClick()
    public void onClick() {
    }
}